﻿using System.Threading.Tasks;
using TimServerSDK.Core;

namespace TimServerSDK
{
    public abstract class AbstractTimServerApi
    {
        protected abstract string ServiceName { get; }
        protected readonly IRestClientProvider RestClientProvider;

        public AbstractTimServerApi(IRestClientProvider restClientProvider)
        {
            RestClientProvider = restClientProvider;
        }

        protected Task<TResult> PostAsync<TResult>(string servicename, string command, object input)
        {
            return RestClientProvider.PostAsync<TResult>(servicename, command, input);
        }

        protected Task<TResult> PostAsync<TResult>(string command, object input)
        {
            return PostAsync<TResult>(ServiceName, command, input);
        }
    }
}
